

package com.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.User;
import com.example.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: hjz
 * @DataTime: 2024/5/31 16:01
 **/
@RestController
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/user")
    public List<User> InsertUser(){
        User user = new User();
        for (int i = 0; i < 15; i++) {
            /**
             * 根据需求定制id
             * 1、仿身份证id
             * 2、雪花算法
             * 3、自增
             */
            user.setId(i+1);
            user.setUsername("hjz"+(i+1));
            user.setPassword("888888"+(i+1));
            user.setPhone("11122223333");
            user.setName("黄锦忠"+(i+1));
            userService.save(user);
        }
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        //模糊查询
        userQueryWrapper.like("name","黄锦忠");
        return userService.list(userQueryWrapper);
    }
}
